Skip to content

hint for mapping request payload error messages #19121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2023
Merged

Conversation

dbu
Copy link
Contributor

@dbu dbu commented Nov 8, 2023

The information is particularly important in the context of the MapRequestPayload but technically not related. It is about the behaviour of the symfony error handler. If there is more documentation about the error handler and output formats, i am happy to link to that if you point me to the right place.

I think it is valuable to mention this here though, as it will happen when using the feature. I almost gave up and set up some custom exception listener or whatnot to output json. Stackoverflow is full of answers proposing those to output errors as JSON.

@OskarStark
Copy link
Contributor

Target 5.4 I guess?

format. This will make the error handling output a JSON response in case of
validation errors, rather than an HTML page::

#[Route('/dashboard', name: 'dashboard', format: 'json')]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the build fails on this. should we make it a different type of code block or do we need to add php code to make the ci happy?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can ignore it

Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
@dbu
Copy link
Contributor Author

dbu commented Nov 9, 2023

i found the place to reference the format option and linked it.

Target 5.4 I guess?

this hint is about MapRequestPayload which has been added in version 6.3.

if there is documentation about working with the error handler in general, it would make sense to add it there. but https://symfony.com/components/ErrorHandler is empty.

https://symfony.com/doc/current/controller/error_pages.html#overriding-error-output-for-non-html-formats talks about custom normalizers - maybe somewhere in that chapter a hint would make sense.

@OskarStark OskarStark added this to the 6.3 milestone Nov 9, 2023
@OskarStark
Copy link
Contributor

Thank you David.

@OskarStark OskarStark merged commit f205e2c into symfony:6.3 Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants